#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL.h>
#include "header.h"

int reglejeu()
{
    /*************Déclaration**************/

    SDL_Event event;
    SDL_Rect  desti;
    SDL_Surface *ecran2, *image2,*retour;
    int done=1;
    /**************************************/

    atexit(SDL_Quit);

    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf( "Echec d'initialisation de SDL.\n");

    }

        printf("SDL est initialisé avec succès.\n");


    ecran2 = SDL_SetVideoMode(960, 640, 32, SDL_ANYFORMAT|SDL_FULLSCREEN);
    if ( ecran2 == NULL )
    {
        printf("Echec de creation de la fenetre\n");
    }

    else
    {
        image2 = SDL_LoadBMP("data/img/regledujeu.bmp");
    }
    if ( image2 == NULL )
    {
        printf("Echec de chargement du fichier regledujeu1.bmp\n");

    }
    retour = SDL_LoadBMP("data/img/retour.bmp");
    if ( retour == NULL )
    {
        printf( "Echec de chargement du fichier retour.bmp\n ");
        return 1;
    }



    SDL_SetColorKey(retour, SDL_SRCCOLORKEY, SDL_MapRGB(retour->format, 255, 255, 255));

    desti.x = 50;
    desti.y = 50;
    desti.w = retour->w;
    desti.h = retour->h;

     SDL_BlitSurface(image2, NULL, ecran2, NULL);
        SDL_BlitSurface(retour, NULL, ecran2, &desti);
        SDL_UpdateRect(ecran2, 0, 0, 0, 0);
         SDL_EnableKeyRepeat(10,10);

     while(done)
    {
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT:
                done = 0;
                break;
                   {
            case SDL_MOUSEBUTTONUP:
                if (event.button.button == SDL_BUTTON_LEFT && desti.x < event.button.x && event.button.x < desti.x + retour->w &&
                        desti.y < event.button.y && event.button.y < desti.y + retour->h)
                    menu();break;}
                    while(done)
    {

               case SDL_KEYDOWN:

                if (event.key.keysym.sym == SDLK_ESCAPE)
                done = 0;
                break;







}
}}}}
